<template>
  <div v-if="type === '1'" class="other-btn-container">
    <a-space :size="8">
      <div v-for="(item, index) in props.btnList" :key="index">
        <div v-if="item.type === 'Select'" class="selebox" style="padding: 3px">
          <div style="width: 80px; margin: 0 3px">
            {{ item.name + '：' }}
          </div>

          <dict-select
            v-model="form.test"
            style="width: 200px"
            allow-clear
            dict-type="businessSelectionPrinciples"
            placeholder="请选择"
            @change="changeselect(item.func, item.type, item.typeChange)"
          ></dict-select>
        </div>
        <div v-else-if="item.typeChange === 'uploadBatch'">
          <a-button
            v-permission="item.permission || []"
            @click="btnClick(item.func, item.type, item.typeChange)"
          >
            <span>
              {{ item.name }}
            </span>
          </a-button>
        </div>
        <div v-else>
          <a-button
            v-if="item?.content"
            :disabled="
              (item.dis !== 'dis' &&
                props.otherParams?.selectedKeys?.length === 0) ||
              (item.dis !== 'dis' &&
                props.otherParams?.selectedKeys2?.length === 0)
            "
            @click="btnClick(item.func, item.type, item.typeChange)"
          >
            <span>
              {{ item.name }}
              <a-tooltip :content="item.content" background-color="#165DFF">
                <icon-exclamation-circle />
              </a-tooltip>
            </span>
          </a-button>

          <a-button
            v-else
            v-permission="item.permission || []"
            :disabled="
              (item.dis !== 'dis' &&
                props.otherParams?.selectedKeys?.length === 0) ||
              (item.dis !== 'dis' &&
                props.otherParams?.selectedKeys2?.length === 0)
            "
            @click="btnClick(item.func, item.type, item.typeChange)"
          >
            {{ item.name }}
          </a-button>
        </div>
      </div>
    </a-space>
  </div>

  <div v-if="type === '2'" class="row-btn-container">
    <a-space :size="16">
      <a-button
        v-for="(item, index) in firstList"
        :key="item.name + index"
        type="text"
        @click="btnClick(item.func, item.type, item.typeChange)"
        >{{ item.name }}</a-button
      >
      <a-dropdown v-if="lastList.length > 0" @select="handleSelect">
        <span class="btn-class1">···</span>
        <template #content>
          <a-doption
            v-for="(ite, ind) in lastList"
            :key="ite.name + ind"
            class="btn-class3"
            type="text"
            @click="btnClick(ite.func, ite.type, ite.typeChange)"
            >{{ ite.name }}</a-doption
          >
        </template>
      </a-dropdown>
    </a-space>
  </div>

  <div v-if="type === '3'" :class="screenClass">
    <div class="selebox">
      <span
        v-if="props.otherParams.popUpComflag"
        class="btn-class2"
        style="margin-right: 12px"
        @click="compilechange"
        >供应商选择文件上传</span
      >
      <span
        v-if="props.otherParams.popUpComflag"
        class="btn-class4"
        @click="compilechange2"
        >编辑</span
      >
      <span
        v-if="props.otherParams.detailswitchflag"
        v-permission="props.otherParams.permission || []"
        class="btn-class"
        @click="openModall"
        >详情</span
      >
      <span
        v-if="
          props.otherParams.detailswitchflag &&
          props.otherParams.activeRadio === '5'
        "
        class="btn-class"
        @click="openModall2"
        >上传文件</span
      >
    </div>
    <div>
      <contentModel
        v-if="showModal"
        title="供应商信息"
        :has-footer="false"
        @close="closeModal"
      >
        <table-container
          v-model:columns="columns"
          v-model:is-fullscreen="isFullscreen"
          :loading="isLoading2"
          :all-columns="allColumns"
          @refresh="getData"
        >
          <template #container-side="{ record, rowIndex }">
            <batchBtn
              :btn-list="props.otherParams.btnList2"
              :other-params="{
                record,
                rowIndex,
                selectedKeys2,
              }"
              type="1"
              @result="rowClickResult3"
            ></batchBtn>
          </template>
          <standard-table
            v-model:selectedKeys="selectedKeys2"
            :component-config="tableComponentConfig"
            :render-config="tableRenderConfig"
            :render-keys="props.otherParams.tableRenderKeys2"
            :loading="isLoading2"
            :data="renderData2"
            :total="total"
            row-selection-type="checkbox"
            :columns="columns"
            height="calc(100vh - 324px)"
            @init-columns-end="initColumns"
            @selection-change="selectionChange2"
            @page-change="pageChange"
            @page-size-change="pageSizeChange"
          >
            <template #operate="{ record, rowIndex }">
              <batchBtn
                :other-params="{
                  record,
                  rowIndex,
                  selectedKeys2,
                  optionCode,
                  activeRadio,
                }"
                type="4"
                @result="rowClickResult2"
              ></batchBtn>
            </template>
          </standard-table>
        </table-container>
      </contentModel>
    </div>
  </div>

  <div v-if="type === '4'">
    <span
      v-permission="['procurement:quote-item:updateQuoteItem']"
      class="btn-class"
      @click="handleEditchild"
      >编辑</span
    >
  </div>

  <!-- 弹窗 -->
  <popUp
    v-if="popVisible"
    :title-text="popUpTitle"
    :content-text="''"
    :width="1350"
    @handle-ok="handleOk"
    @handle-cancel="handleCancel"
  >
    <template #content>
      <a-form
        v-if="compilechangeflag"
        ref="formRef"
        :model="pushdata.form"
        :rules="formRules"
      >
        <a-row :gutter="16">
          <a-col :span="9">
            <a-form-item
              field="planerPhone"
              label="计划员电话："
              label-col-flex="100px"
            >
              <a-input
                v-model="pushdata.form.planerPhone"
                placeholder="请输入手机号"
              />
            </a-form-item>
          </a-col>
          <a-col :span="15">
            <a-form-item
              field="time"
              label="报价截止日期："
              label-col-flex="180px"
            >
              <a-range-picker
                v-model="pushdata.form.time"
                :allow-clear="true"
                style="width: 254px; margin-bottom: 20px"
                @change="onChange"
              />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="16">
          <a-col :span="13">
            <a-form-item
              field="time2"
              label="报价截止日期："
              label-col-flex="120px"
            >
              <a-range-picker
                v-model="pushdata.form.time2"
                :allow-clear="true"
                style="width: 254px; margin-bottom: 20px"
                @change="onChange"
              />
            </a-form-item>
          </a-col>
          <a-col :span="10">
            <a-form-item
              field="planerPhone"
              label="供应商联系人："
              label-col-flex="100px"
            >
              <inputModal
                v-model="pushdata.form.planerPhone"
                :label-value="pushdata.form.planerPhone"
                :value-name="'taskNum'"
                :label-name="'taskNum'"
                :title="'供应商联系人'"
                :type="'missionNo'"
              >
              </inputModal>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>

      <a-form
        v-if="handleEditchildflag"
        ref="formRef2"
        :model="pushdata.form"
        :rules="formRules"
        auto-label-width
      >
        <!-- 选商方式确认子表单新增+编辑 -->
        <a-row
          v-if="appendflag && props.otherParams?.optionCode !== 'quotation'"
          :gutter="16"
        >
          <a-col :span="5">
            <!-- <a-form-item
              field="secretLevel"
              label="密级："
              label-col-flex="70px"
            >
              <a-input v-model="pushdata.form.secretLevel" placeholder="" />
            </a-form-item> -->
            <a-form-item
              field="supplierLinkmanName"
              label="供应商联系人："
              label-col-flex="100px"
            >
              <inputModal
                v-model="pushdata.form.supplierLinkmanName"
                :label-value="pushdata.form.supplierLinkmanName"
                :value-name="'supplierChinese'"
                :title="'供应商联系人：'"
                :type="'supplyName'"
              />
              <!-- @handle-ok="selectSupplier2" -->
            </a-form-item>
            <!-- <a-form-item
              field="measureCode"
              label="基本计量单位："
              label-col-flex="130px"
            >
              <dict-select
                v-model="pushdata.form.measureCode"
                style="width: 200px"
                allow-clear
                dict-type="unitOfMeasurement"
                placeholder="请选择"
              ></dict-select>
            </a-form-item> -->
            <a-form-item
              field="inputType"
              label="录入类型："
              label-col-flex="100px"
            >
              <a-select
                v-model="pushdata.form.inputType"
                placeholder="请选择"
                @change="selChange"
              >
                <a-option
                  v-for="item of dictList"
                  :key="item.value"
                  :value="item.value"
                  :label="item.label"
                />
              </a-select>
            </a-form-item>
            <a-form-item
              v-if="props.otherParams?.activeRadio !== '5'"
              field="pmsInvTaxPrice"
              label="含税结算单价："
              label-col-flex="130px"
            >
              <a-input
                v-model="pushdata.form.pmsInvTaxPrice"
                placeholder=""
                :disabled="selChangeflag"
              />
              <!-- @change="handleChangepmsInvTaxPrice" -->
            </a-form-item>
            <a-form-item field="note" label="备注：" label-col-flex="70px">
              <a-input v-model="pushdata.form.note" placeholder="" />
            </a-form-item>
            <a-form-item
              v-if="props.otherParams?.activeRadio !== '5'"
              field="pmsBalancePrice"
              label="不含税结算单价："
              label-col-flex="130px"
            >
              <a-input
                v-model="pushdata.form.pmsBalancePrice"
                placeholder=""
                :disabled="selChangeflag2"
              />
              <!-- @change="handleChangepmsBalancePrice" -->
            </a-form-item>
          </a-col>
          <a-col :span="5">
            <!-- <a-form-item
              field="serialnumber"
              label="序号："
              label-col-flex="70px"
            >
              <a-input v-model="pushdata.form.serialnumber" placeholder="" />
            </a-form-item> -->
            <a-form-item
              field="supplierLinkmanTel"
              label="供应商联系电话："
              label-col-flex="130px"
            >
              <a-input
                v-model="pushdata.form.supplierLinkmanTel"
                placeholder=""
              />
            </a-form-item>
            <a-form-item
              field="mdsUintRate"
              label="转换系数："
              label-col-flex="100px"
            >
              <a-input v-model="pushdata.form.mdsUintRate" placeholder="" />
              <!-- @change="handleChangemdsUintRate" -->
            </a-form-item>
            <a-form-item
              field="exTaxPrice"
              label="不含税单价："
              label-col-flex="120px"
            >
              <a-input
                v-model="pushdata.form.exTaxPrice"
                placeholder=""
                :disabled="selChangeflag2"
              />
              <!-- @change="handleChangeexTaxPrice" -->
            </a-form-item>
            <a-form-item
              field="pmsEstimatePrice"
              label="预估价："
              label-col-flex="70px"
            >
              <a-input
                v-model="pushdata.form.pmsEstimatePrice"
                placeholder=""
              />
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item
              field="supplierCode"
              label="供应商编码："
              label-col-flex="100px"
            >
              <inputModal
                v-model="pushdata.form.supplierCode"
                :label-value="pushdata.form.supplierCode"
                :value-name="'creditCode'"
                :title="'供应商编码：'"
                :type="'supplyName'"
              />
            </a-form-item>
            <!-- <a-form-item
              field="pmsInvPrice"
              label="采购单价（库存）："
              label-col-flex="130px"
            >
              <a-input v-model="pushdata.form.pmsInvPrice" placeholder="" />
            </a-form-item> -->
            <a-form-item
              field="invPurQty"
              label="采购数量（采购）："
              label-col-flex="130px"
            >
              <a-input v-model="pushdata.form.invPurQty" placeholder="" />
              <!-- @change="handleChangeinvPurQty" -->
            </a-form-item>
            <a-form-item
              field="taxRateCode"
              label="税率："
              label-col-flex="70px"
            >
              <dict-select
                v-model="pushdata.form.taxRateCode"
                style="width: 500px"
                allow-clear
                dict-type="taxRate"
                placeholder="请选择"
              ></dict-select>
            </a-form-item>
            <a-form-item
              field="currencyType"
              label="币种："
              label-col-flex="70px"
            >
              <dict-select
                v-model="pushdata.form.currencyType"
                style="width: 500px"
                allow-clear
                dict-type="currencyType"
                placeholder="请选择"
              ></dict-select>
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item
              field="supplierName"
              label="供应商名称："
              label-col-flex="100px"
            >
              <a-input v-model="pushdata.form.supplierName" placeholder="" />
            </a-form-item>
            <!-- <a-form-item
              field="pmsInvQty"
              label="采购数量（库存）："
              label-col-flex="130px"
            >
              <a-input v-model="pushdata.form.pmsInvQty" placeholder="" />
            </a-form-item> -->
            <!-- @change="handleChangepmsInvQty" -->
            <a-form-item
              field="pmsMdsUnitCode"
              label=" 计量单位（采购）："
              label-col-flex="180px"
            >
              <dict-select
                v-model="pushdata.form.pmsMdsUnitCode"
                style="width: 200px"
                allow-clear
                dict-type="unitOfMeasurement"
                placeholder="请选择"
              ></dict-select>
            </a-form-item>
            <a-form-item
              field="taxPrice"
              label="含税单价："
              label-col-flex="70px"
            >
              <a-input
                v-model="pushdata.form.taxPrice"
                placeholder=""
                :disabled="selChangeflag"
              />
              <!-- @change="handleChangetaxPrice" -->
            </a-form-item>
            <a-form-item
              v-if="props.otherParams?.activeRadio !== '5'"
              field="choiceTage"
              label="选择结果："
              label-col-flex="70px"
            >
              <!-- <dict-select
                v-model="pushdata.form.choiceTage"
                style="width: 200px"
                allow-clear
                dict-type="loginReultType"
                placeholder="请选择"
              ></dict-select> -->
              <a-select
                v-model="pushdata.form.choiceTage"
                placeholder="请选择"
                @change="selChange2"
              >
                <a-option
                  v-for="item of dictList2"
                  :key="item.value"
                  :value="item.value"
                  :label="item.label"
                />
              </a-select>
            </a-form-item>
          </a-col>
        </a-row>

        <!-- 报价信息维护子表单编辑 -->
        <a-row
          v-if="props.otherParams?.optionCode === 'quotation' && appendflag"
          :gutter="16"
        >
          <a-col :span="6">
            <a-form-item field="mdsItemCode" label="物料编码：">
              <a-input
                v-model="pushdata.form.mdsItemCode"
                placeholder=""
                disabled
              />
            </a-form-item>
            <a-form-item field="inputType" label="录入类型：">
              <a-select
                v-model="pushdata.form.inputType"
                placeholder="请选择"
                @change="selChange"
              >
                <a-option
                  v-for="item of dictList"
                  :key="item.label"
                  :value="item.value"
                  :label="item.label"
                />
              </a-select>
            </a-form-item>
            <a-form-item field="deliveryDays" label="交货周期（天）：">
              <a-input v-model="pushdata.form.deliveryDays" placeholder="" />
            </a-form-item>
            <a-form-item field="itemManufactureFactory" label="生产制造厂家：">
              <inputModal
                v-model="pushdata.form.itemManufactureFactoryId"
                :label-value="pushdata.form.itemManufactureFactory"
                :label-name="'supplierChinese'"
                :value-name="'id'"
                :title="'生产制造厂家：'"
                :type="'supplyName'"
                @handle-ok="selectSupplier"
              />
            </a-form-item>
            <a-form-item
              field="itemManufactureFactoryCode"
              label="生产制造厂家编码："
            >
              <a-input
                v-model="pushdata.form.itemManufactureFactoryCode"
                placeholder=""
                disabled
              />
            </a-form-item>
            <a-form-item field="quoteQty" label="报价数量（采购）：">
              <a-input
                v-model="pushdata.form.quoteQty"
                placeholder=""
                disabled
              />
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item field="taxRateCode" label="税率：">
              <dict-select
                v-model="pushdata.form.taxRateCode"
                allow-clear
                dict-type="taxRate"
                placeholder="请选择"
              ></dict-select>
            </a-form-item>
            <a-form-item field="quoterName" label="报价人：">
              <a-input v-model="pushdata.form.quoterName" placeholder="" />
            </a-form-item>
            <a-form-item field="notes" label="备注：">
              <a-input v-model="pushdata.form.notes" placeholder="" />
            </a-form-item>
            <a-form-item field="pmsPredictPrice" label="预估价：">
              <a-input v-model="pushdata.form.pmsPredictPrice" placeholder="" />
            </a-form-item>
            <a-form-item field="mdsUintRate" label="转换系数：">
              <a-input v-model="pushdata.form.mdsUintRate" @blur="execChange" />
            </a-form-item>
            <a-form-item field="pmsInvQty" label="询价数量(库存)">
              <a-input
                v-model="pushdata.form.pmsInvQty"
                placeholder=""
                disabled
              />
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item field="provisionalSum" label="暂列金额：">
              <a-input v-model="pushdata.form.provisionalSum" placeholder="" />
            </a-form-item>
            <a-form-item field="invUnitPrice" label="单价（采购）">
              <a-input-number
                v-model="pushdata.form.invUnitPrice"
                placeholder=""
                @blur="execChange"
              />
            </a-form-item>
            <a-form-item field="pmsIndentLeastQty" label="最小采购批量：">
              <a-input
                v-model="pushdata.form.pmsIndentLeastQty"
                placeholder=""
              />
            </a-form-item>
            <a-form-item field="dealerName" label="经销商：">
              <inputModal
                v-model="pushdata.form.dealerId"
                :label-value="pushdata.form.dealerName"
                :label-name="'supplierChinese'"
                :value-name="'id'"
                :title="'经销商：'"
                :type="'supplyName'"
                @handle-ok="selectSupplier2"
              />
            </a-form-item>
            <a-form-item field="dealerCode" label="经销商编码：">
              <a-input
                v-model="pushdata.form.dealerCode"
                placeholder=""
                disabled
              />
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item field="currencyType" label="币种：">
              <dict-select
                v-model="pushdata.form.currencyType"
                allow-clear
                dict-type="currencyType"
                placeholder="请选择"
              ></dict-select>
            </a-form-item>
            <a-form-item field="pmsMdsUnitCode" label=" 计量单位（采购）：">
              <dict-select
                v-model="pushdata.form.pmsMdsUnitCode"
                style="width: 200px"
                allow-clear
                dict-type="unitOfMeasurement"
                placeholder="请选择"
              ></dict-select>
            </a-form-item>
            <a-form-item field="quoteValidDate" label="报价有效期：">
              <a-date-picker
                v-model="pushdata.form.quoteValidDate"
                style="width: 220px; margin: 0 24px 24px 0"
                :time-picker-props="{ defaultValue: '09:09:06' }"
                format="YYYY-MM-DD"
                @ok="onOk"
              />
            </a-form-item>
            <a-form-item field="quoteDate" label="报价日期：">
              <a-date-picker
                v-model="pushdata.form.quoteDate"
                style="width: 220px; margin: 0 24px 24px 0"
                :time-picker-props="{ defaultValue: '09:09:06' }"
                format="YYYY-MM-DD"
                @ok="onOk2"
              />
            </a-form-item>
            <a-form-item field="pmsInvPrice" label="采购单价（库存）：">
              <a-input
                v-model="pushdata.form.pmsInvPrice"
                placeholder=""
                disabled
              />
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>

      <a-form
        v-if="handleEditchildflag2"
        ref="formRef3"
        :model="pushdata.form"
        :rules="formRules"
      >
        <!-- 单一来源采购编辑 -->
        <a-row v-if="appendflag2" :gutter="16">
          <a-col :span="8">
            <a-form-item
              field="mdsUintRate"
              label="转换系数："
              label-col-flex="130px"
            >
              <a-input v-model="pushdata.form.mdsUintRate" placeholder="" />
            </a-form-item>
            <a-form-item
              field="inputType"
              label="录入类型："
              label-col-flex="90px"
            >
              <!-- <dict-select
                v-model="pushdata.form.inputType"
                style="width: 200px"
                allow-clear
                dict-type="inputType"
                placeholder="请选择"
              ></dict-select> -->
              <a-select
                v-model="pushdata.form.inputType"
                placeholder="请选择"
                @change="selChange"
              >
                <a-option
                  v-for="item of dictList"
                  :key="item.value"
                  :value="item.value"
                  :label="item.label"
                />
              </a-select>
            </a-form-item>
            <a-form-item
              field="pmsInvQty"
              label="计划数量(库存):"
              label-col-flex="120px"
            >
              <a-input v-model="pushdata.form.pmsInvQty" placeholder="" />
            </a-form-item>
            <a-form-item
              field="pmsMdsUnitCode"
              label=" 计量单位（采购）："
              label-col-flex="180px"
            >
              <dict-select
                v-model="pushdata.form.pmsMdsUnitCode"
                style="width: 200px"
                allow-clear
                dict-type="unitOfMeasurement"
                placeholder="请选择"
              ></dict-select>
            </a-form-item>
            <a-form-item
              field="taxPrice"
              label="含税单价："
              label-col-flex="70px"
            >
              <a-input
                v-model="pushdata.form.taxPrice"
                placeholder=""
                :disabled="selChangeflag"
              />
            </a-form-item>
          </a-col>

          <a-col :span="8">
            <a-form-item
              field="pmsEstimatePrice"
              label="预估价："
              label-col-flex="70px"
            >
              <a-input
                v-model="pushdata.form.pmsEstimatePrice"
                placeholder=""
              />
            </a-form-item>
            <a-form-item
              field="exTaxPrice"
              label="不含税单价(采购)："
              label-col-flex="160px"
            >
              <a-input
                v-model="pushdata.form.exTaxPrice"
                placeholder=""
                :disabled="selChangeflag2"
              />
            </a-form-item>
            <a-form-item
              field="taxRateCode"
              label="税率："
              label-col-flex="70px"
            >
              <dict-select
                v-model="pushdata.form.taxRateCode"
                style="width: 200px"
                allow-clear
                dict-type="taxRate"
                placeholder="请选择"
              ></dict-select>
            </a-form-item>
            <a-form-item
              field="invPurQty"
              label="计划数量(采购):"
              label-col-flex="120px"
            >
              <a-input v-model="pushdata.form.invPurQty" placeholder="" />
            </a-form-item>
            <a-form-item
              field="currencyType"
              label="币种："
              label-col-flex="70px"
            >
              <dict-select
                v-model="pushdata.form.currencyType"
                style="width: 200px"
                allow-clear
                dict-type="currencyType"
                placeholder="请选择"
              ></dict-select>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </template>
  </popUp>

  <!-- 批量上传 -->
  <batchImport
    v-if="batchVisible"
    :import-url="importurl"
    :export-url="exportUrl"
    :params="{ planListNo }"
    @close-drawer="closeDrawer"
    @finish="finish"
  ></batchImport>

  <!-- 文件导入  -->
  <fileUpload
    v-if="fileValueflag"
    v-model="fileValue"
    :selected-id="props.otherParams.selectedKeys"
    type="2"
    btn-name="文件上传"
    btn-type="text"
    title="Excel导入"
    accept=".xlsx"
    :max-size="0.1"
    @restion="fileValueflagfun"
  />
</template>

<script lang="ts" setup>
  import useModal from '@/common/hooks/modal';
  import {
    defineProps,
    defineEmits,
    ref,
    defineAsyncComponent,
    onMounted,
    watch,
  } from 'vue';
  import {
    selectQuoteItemByPage,
    updateQuoteItem,
    batchUpdateQuoteStatus,
    batchQuoteFinish,
  } from '@/api/supplier/quotation-information-maintenance';
  import {
    batchSaveOrUpdate,
    batchUpdateForSimple, // 单一来源编辑提交
    pageByPlanListNo, // 获取子表单数据
    plansupplier, // 子表单 删除
    doWBid, // 供应商中标
    doNWBid, // 供应商取消中标
    exportBxcg, // 比选采购 导出
    exportCompeteNegotiation, // 竞争性谈判 导出
    exportZtb, // 招投标 导出
    checkTender, // 添加时候判断planListNo有无
    // execTaxCalculate, // (含税、不含税)单价相关计算
    // execUintRateCalculate, // 转化系数相关计算
    execTaxCalculates,
  } from '@/api/supplier/selective-quotient';
  import { Message, Notification } from '@arco-design/web-vue';
  import dictSelect from '@/common/components/dict-select/index.vue';
  import tableContainer from '@/common/components/table-container/index.vue';
  import StandardTable from '@/common/components/standard-table/index.vue';
  import inputModal from '@/common/components/search-modal/input-modal.vue';
  import useFullScreen from '@/common/hooks/fullScreen';
  import batchImport from '@/common/components/batch-import/import-container.vue';
  import dayjs from 'dayjs';
  import lodash from 'lodash';
  import fileUpload from './file-upload-page/index.vue';
  import popUp from './pop-up.vue';

  import {
    tableRenderConfig,
    tableComponentConfig,
  } from './tableComp/baseTableConfig';

  const contentModel = defineAsyncComponent(
    () => import('@/common/components/content-model/index.vue')
  );

  const { isFullscreen, screenClass } = useFullScreen();
  const { showModal, closeModal, openModal } = useModal();
  const emit = defineEmits(['result', 'refresh']);

  const columns = ref<object[]>([]);
  const isLoading2 = ref(false); // 子级表格控制loading状态
  const popVisible = ref(false);
  const appendflag = ref(false);
  const appendflag2 = ref(false);
  const selChangeflag = ref(false);
  const selChangeflag2 = ref(false);
  const fileValueflag = ref(false); // 表单单条信息详情开关
  const batchVisible = ref(false); // 批量上传
  const importurl = ref('');
  const planListNo = ref('');
  const exportUrl = ref('');
  const fileValue = ref({});

  const allColumns = ref<object[]>([]);
  const selectedKeys2 = ref<any[]>([]);
  const renderData2 = ref<any[]>([]);
  const popUpTitle = ref<string>('');
  const form = ref({
    test: '',
  });
  const firstList = ref<any[]>([]);
  const lastList = ref<any[]>([]);
  const compilechangeflag = ref(false);
  const handleEditchildflag = ref(false);
  const handleEditchildflag2 = ref(false);
  const optionCode = ref('');
  const codethis = ref<number>();
  codethis.value = props.thiscode ? props.thiscode : 0;
  optionCode.value = props.typecode ? props.typecode : '';
  const pageNo = ref<number>(1);
  const pageSize = ref<number>(10);
  const recordid = ref('');
  const formRef = ref<any>();
  const formRef2 = ref<any>();
  const formRef3 = ref<any>();
  // 编辑的内容
  const pushdata = ref({
    selectedKeys: [],
    form: {
      id: props.otherParams?.record?.id || '', // 编辑的id
      planerPhone: props.otherParams?.record?.planerPhone || '', // 计划员电话
      // secretLevel: props.otherParams?.record?.secretLevel || '', // 密级
      // serialnumber: props.otherParams?.record?.serialnumber || '', // 序号
      supplierLinkmanName: props.otherParams?.record?.supplierLinkmanName || '', // 供应商联系人
      supplierLinkmanTel: props.otherParams?.record?.supplierLinkmanTel || '', // 供应商联系电话
      pmsInvPrice: props.otherParams?.record?.pmsInvPrice || '', // 采购单价（库存）
      pmsInvQty: props.otherParams?.record?.pmsInvQty || '', // 采购数量（库存）
      // measureCode: props.otherParams?.record?.measureCode || '', // 基本计量单位
      mdsUintRate: props.otherParams?.record?.mdsUintRate || '', // 转换系数
      invPurQty: props.otherParams?.record?.pmsInvQty || '', // 采购数量（采购） 采购 = 库存
      pmsMdsUnitCode: props.otherParams?.record?.pmsMdsUnitCode || '', // 计量单位（采购）
      inputType: props.otherParams?.record?.inputType || '', // 录入类型
      pmsBalancePrice: props.otherParams?.record?.pmsBalancePrice || '', // 不含税结算单价
      exTaxPrice: props.otherParams?.record?.exTaxPrice || '', // 不含税单价
      taxPrice: props.otherParams?.record?.taxPrice || '', // 含税单价
      pmsInvTaxPrice: props.otherParams?.record?.pmsInvTaxPrice || '', // 含税结算单价
      pmsEstimatePrice: props.otherParams?.record?.pmsEstimatePrice || '', // 预估价
      pmsPredictPrice: props.otherParams?.record?.pmsPredictPrice || '', // 预估价
      currencyType: props.otherParams?.record?.currencyType || '', // 币种
      choiceTage: props.otherParams?.record?.choiceTage || '', // 选择结果
      note: props.otherParams?.record?.note || '', // 备注
      notes: props.otherParams?.record?.notes || '', // 备注
      mdsItemCode: props.otherParams?.record?.mdsItemCode || '', // 物料编码
      deliveryDays: props.otherParams?.record?.deliveryDays || '', // 交货周期（天）
      quoterName: props.otherParams?.record?.quoterName || '', // 报价人
      itemManufactureFactoryId:
        props.otherParams?.record?.itemManufactureFactoryId || '', // 生产制造厂家ID
      itemManufactureFactory:
        props.otherParams?.record?.itemManufactureFactory || '', // 生产制造厂家名称
      itemManufactureFactoryCode:
        props.otherParams?.record?.itemManufactureFactoryCode || '', // 生产制造厂家编码
      provisionalSum: props.otherParams?.record?.provisionalSum || '', // 暂列金额
      taxRateCode: props.otherParams?.record?.taxRateCode || '', // 筛选框税率
      invUnitPrice: props.otherParams?.record?.invUnitPrice || '', // 单价（采购）
      pmsIndentLeastQty: props.otherParams?.record?.pmsIndentLeastQty || '', // 最小采购批量
      dealerId: props.otherParams?.record?.dealerId || '', // 经销商ID
      dealerName: props.otherParams?.record?.dealerName || '', // 经销商
      dealerCode: props.otherParams?.record?.dealerCode || '', // 经销商编码
      quoteValidDate: props.otherParams?.record?.quoteValidDate || '', // 报价有效期
      quoteDate: props.otherParams?.record?.quoteDate || '', // 报价日期
      quoteQty: props.otherParams?.record?.quoteQty || '', // 报价数量（采购）
      planListNo: props.otherParams?.record?.planListNo || '', // 计划编号
      supplierName: props.otherParams?.record?.supplierName || '', // 供应商名称
      supplierId: props.otherParams?.record?.supplierId || '', // 供应商主键
      supplierCode: props.otherParams?.record?.supplierCode || '', // 供应商编码
      measureCode: props.otherParams?.record?.measureCode || '', // 基本单位
    },
  });
  const formRules = ref({
    pmsMdsUnitCode: [
      {
        required: true,
        message: '计量单位不能为空',
        trigger: 'change',
      },
    ],
    secretLevel: [
      {
        required: true,
        message: '密级不能为空',
        trigger: 'change',
      },
    ],
    time2: [
      {
        required: true,
        message: '请选择报价截止日期',
        trigger: 'change',
      },
    ],
    planerPhone2: [
      { required: true, message: '请填写联系电话', trigger: 'blur' },
      {
        pattern: /^1[3-9]\d{9}$/,
        message: '请输入有效的手机号',
        trigger: 'blur',
      },
    ],
    mdsUintRate: [
      {
        required: true,
        message: '请输入转换系数',
        trigger: 'change',
      },
    ],
    currencyType: [
      {
        required: true,
        message: '请选择币种',
        trigger: 'change',
      },
    ],
    inputType: [
      {
        required: true,
        message: '请输入录入类型',
        trigger: 'change',
      },
    ],
    taxRateCode: [
      {
        required: true,
        message: '请选择税率',
        trigger: 'change',
      },
    ],
    invUnitPrice: [
      {
        required: true,
        message: '请输入单价(采购)',
        trigger: 'change',
      },
    ],
    // pmsMdsUnitCode: [
    //   {
    //     required: true,
    //     message: '请输入计量单位(采购)',
    //     trigger: 'change',
    //   },
    // ],
  });
  const dictList = ref([
    {
      label: '含税单价录入',
      value: '1',
    },
    {
      label: '不含税单价录入',
      value: '0',
    },
  ]);
  const dictList2 = ref([
    {
      label: '是',
      value: 1,
    },
    {
      label: '否',
      value: 0,
    },
  ]);
  const recordBtnkey = ref('');

  const props = defineProps({
    btnList: {
      type: Array<any>,
      default: () => [],
    },
    type: {
      type: String,
      default: '1',
    },
    typecode: {
      type: String,
    },
    otherParams: {
      type: Object,
    },
    thiscode: {
      type: Number,
    },
  });

  props.btnList.forEach((item) => {
    if (item.type === '1') {
      firstList.value.push(item);
    } else if (item.type === '2') {
      lastList.value.push(item);
    }
  });

  // 批量上传
  const closeDrawer = (flag: boolean) => {
    console.log(flag, '关闭弹窗');
    batchVisible.value = flag;
  };

  // 批量上传后的完成事件
  const finish = async (response: any, secretLevel: string, flag: boolean) => {
    console.log(response, secretLevel, flag, '完成');
    batchVisible.value = flag;
    await getlist2(props.otherParams?.record?.id);
  };

  const fileValueflagfun = (flag: any) => {
    fileValueflag.value = flag;
  };

  const getData = async (queryInfo: any) => {
    console.log('queryInfo', queryInfo);
    isLoading2.value = false;
  };

  const selectionChange2 = async (val: string[]) => {
    selectedKeys2.value = val;
    console.log('selectedKeys2', val, selectedKeys2.value, props.thiscode);
  };

  const initColumns = (data: any[]) => {
    columns.value = lodash.cloneDeep(data);
    allColumns.value = lodash.cloneDeep(data);
  };

  const pageChange = (val: any) => {
    console.log('pageChange', val, recordid.value);
    pageNo.value = val.pageNo;
    pageSize.value = val.pageSize;
    getlist(recordid);
  };

  const pageSizeChange = (val: number) => {
    console.log('pageSizeChange', val);
  };

  // 导出
  const exportCpWzdapi = async (api: any, name: string) => {
    try {
      const res = (await api({
        planListNo: props.otherParams?.record?.planListNo,
      })) as any;
      console.log(res);
      if (res.code === null || res.code === undefined) {
        const elink = document.createElement('a');
        elink.download = `${name}${dayjs()
          .format('YYYY-MM-DD_HH:mm:ss')
          .toString()}.xlsx`;
        elink.style.display = 'none';
        const blob = new Blob([res], { type: 'application/vnd.ms-excel' });
        console.log(blob);
        elink.href = URL.createObjectURL(blob);
        document.body.appendChild(elink);
        elink.click();
        document.body.removeChild(elink);
      } else {
        // 正常情况下文件的下载是不会返回retCode的，如果发现有返回码，说明就是接口出了问题
        Notification.error({
          title: '导出失败！',
          content: res.message,
        });
      }
    } catch (error) {
      // eslint-disable-next-line @typescript-eslint/no-unused-vars
      Notification.error({
        content: `出现异常！${error}`,
        closable: true,
        duration: 20000,
      });
    }
  };

  const rowClickResult2 = (
    type: string,
    typeChange: string,
    selectedKeys2list: any
  ) => {
    console.log('单条列表操作列点击事件', type, typeChange, selectedKeys2list);
  };

  const checkTenderapi = async () => {
    const { data } = await checkTender(props.otherParams?.record?.planListNo);
    if (data) {
      popUpTitle.value = '添加内容';
      compilechangeflag.value = false;
      popVisible.value = true;
      handleEditchildflag.value = true;
      appendflag.value = true;
      clearpushdata();
    } else {
      Message.error('没有计划编号');
    }
  };

  const rowClickResult3 = async (
    record: any,
    rowIndex: any,
    selectedKeys2list: any
  ) => {
    console.log(
      '上面列表操作列点击事件',
      record,
      rowIndex,
      codethis.value,
      selectedKeys2list.selectedKeys2
    );
    recordBtnkey.value = record;
    switch (record) {
      // recordBtnkey.value
      case 'append':
        console.log('添加');
        await checkTenderapi();
        break;
      case 'deleteall':
        Message.success('删除');
        await plansupplier(selectedKeys2list.selectedKeys2);
        await getlist2('1');
        console.log('删除', selectedKeys2list.selectedKeys2);
        break;
      case 'Excelexportztb':
        console.log('Excel导出', selectedKeys2list.selectedKeys2);
        break;
      case 'Exceltochannelztb':
        Message.success('Excel导入');
        console.log('Excel导入', selectedKeys2list.selectedKeys2);
        break;
      case 'winthebidding':
        await doWBid(selectedKeys2list.selectedKeys2);
        Message.success('操作成功');
        console.log('中标', selectedKeys2list.selectedKeys2);
        break;
      case 'Cancelthebid':
        Message.success('操作成功');
        await doNWBid(selectedKeys2list.selectedKeys2);
        console.log('取消中标', selectedKeys2list.selectedKeys2);
        break;
      case 'quotationcompleted888':
        // Message.success('报价完成');
        console.log('报价完成', selectedKeys2list.selectedKeys2);
        await batchQuoteFinishapi(selectedKeys2list.selectedKeys2);
        break;
      case 'notquote888':
        // Message.success('不报价');
        console.log('不报价', selectedKeys2list.selectedKeys2);
        await batchUpdateQuoteStatusapi(selectedKeys2list.selectedKeys2, 0);
        break;
      case 'quote888':
        // Message.success('报价');
        console.log('报价', selectedKeys2list.selectedKeys2);
        await batchUpdateQuoteStatusapi(selectedKeys2list.selectedKeys2, 1);
        break;
      // case 'withdrawtheinquiry888':
      //   Message.success('撤销询比价');
      //   console.log('撤销询比价', selectedKeys2list.selectedKeys2);
      //   break;
      default:
        console.error('Invalid record value');
    }
    switch (codethis.value) {
      case '233' || '333' || '133' || '433' || '533':
        if (record === 'Excelexport') {
          await exportCpWzdapi(exportBxcg, '比选采购导出数据');
        } else if (record === 'Exceltochannel') {
          batchVisible.value = true;
          importurl.value =
            '/api/procurement/require/excelOperation/importBxcg';
          planListNo.value = props.otherParams?.record?.planListNo;
          exportUrl.value =
            'http://10.191.5.215:9000/yiyan/比选采购明细导入模板.xlsx';
        }
        break;
      case '244' || '344' || '144' || '444' || '544':
        if (record === 'Excelexport') {
          await exportCpWzdapi(
            exportCompeteNegotiation,
            '竞争性谈判采购导出数据'
          );
        } else if (record === 'Exceltochannel') {
          batchVisible.value = true;
          importurl.value =
            '/api/procurement/require/excelOperation/importCompeteNegotiation';
          planListNo.value = props.otherParams?.record?.planListNo;
          exportUrl.value =
            'http://10.191.5.215:9000/yiyan/竞争性谈判明细表导入模板.xlsx';
        }
        break;
      case '255' || '355' || '155' || '554' || '555':
        if (record === 'Excelexport') {
          await exportCpWzdapi(exportZtb, '招投标导出数据');
        } else if (record === 'Exceltochannel') {
          batchVisible.value = true;
          importurl.value = '/api/procurement/require/excelOperation/importZtb';
          planListNo.value = props.otherParams?.record?.planListNo;
          exportUrl.value =
            'http://10.191.5.215:9000/yiyan/招投标子表导入模板.xlsx';
        }

        break;
      default:
        console.error('Invalid activeTab.value');
    }
  };

  const changeselect = async (
    func: (params?: any) => void,
    type: string,
    typeChange: string
  ) => {
    if (props.type === '1') {
      await func(props.otherParams);
    } else {
      await func(props.otherParams);
    }
    emit('result', type, typeChange, props.otherParams, form.value.test);
  };

  const btnClick = async (
    func: (params?: any) => void,
    type: string,
    typeChange: string
  ) => {
    if (!form.value.test && ['autoBudget'].includes(typeChange)) {
      Message.warning('请先选择选商原则！');
      return;
    }
    if (props.type === '1') {
      await func(props.otherParams);
    } else {
      await func(props.otherParams);
    }
    emit('result', type, typeChange, props.otherParams, {
      type: form.value.test,
    });
  };

  // const handleSelect = (v: any) => {
  //   console.log(v);
  // };

  const selChange = async (v: any) => {
    console.log(v, 'selectedLabel');
    if (v === '1') {
      selChangeflag.value = false;
      selChangeflag2.value = true;
    } else {
      selChangeflag.value = true;
      selChangeflag2.value = false;
    }
    // const { data } = await execTaxCalculate(pushdata.value.form);
    // pushdata.value.form = data;
    // console.log('====================================');
    // console.log(data);
    // console.log('====================================');
  };
  const selChange2 = async (v: any) => {
    console.log(v, 'selChange2');
  };

  const compilechange = () => {
    console.log(
      '供应商选择文件上传',
      props.otherParams.selectedKeys,
      props.otherParams.popUpComflag
    );
    fileValueflag.value = true;
    emit('result', props.otherParams, popVisible.value);
  };

  const compilechange2 = () => {
    console.log('编辑', props.otherParams?.record);
    // if (props.otherParams.record?.supplierCode) {
    compilechangeflag.value = false;
    handleEditchildflag.value = false;
    handleEditchildflag2.value = true;
    appendflag.value = false;
    appendflag2.value = true;
    popVisible.value = !popVisible.value;
    popUpTitle.value = '修改内容';
    // } else {
    //   Message.error('请先更新供应商再编辑!');
    // }
    emit('result', props.otherParams, popVisible.value);
  };
  const total = ref(0);
  // 置空   pushdata.value
  const clearpushdata = () => {
    pushdata.value = {
      selectedKeys: [],
      form: {
        id: '',
        planerPhone: '',
        // secretLevel: '',
        serialnumber: '',
        supplierLinkmanName: '',
        supplierLinkmanTel: '',
        pmsInvPrice: '',
        pmsInvQty: '',
        measureCode: '',
        mdsUintRate: '',
        invPurQty: '',
        pmsMdsUnitCode: '',
        inputType: '',
        pmsBalancePrice: '',
        exTaxPrice: '',
        taxPrice: '',
        pmsInvTaxPrice: '',
        pmsEstimatePrice: '',
        currencyType: '',
        choiceTage: '',
        note: '',
        notes: '',
        mdsItemCode: '',
        deliveryDays: '',
        quoterName: '',
        itemManufactureFactory: '',
        provisionalSum: '',
        taxRate: '',
        invUnitPrice: '',
        pmsIndentLeastQty: '',
        dealerName: '',
        quoteValidDate: '',
        quoteDate: '',
        dealerCode: '',
        itemManufactureFactoryCode: '',
        quoteQty: '',
        planListNo: '',
        supplierName: '',
        supplierId: '',
        supplierCode: '',
      },
    };
  };

  // 弹窗确认
  const handleOk = async (flag: boolean, done: any) => {
    console.log(
      pushdata.value.form,
      recordBtnkey.value,
      popUpTitle.value,
      '确认信内容'
    );

    if (optionCodebj.value === 'quotation') {
      const val = await formRef2.value.validate();
      if (!val) {
        const { data } = await updateQuoteItem({
          id: props.otherParams?.record?.id,
          planListNo: props.otherParams?.record?.planListNo,
          ...pushdata.value.form,
        });
        if (data) {
          Message.success('修改成功');
        } else {
          Message.error('修改失败');
        }
        popVisible.value = flag;
      } else {
        done(false);
      }
    }

    if (compilechangeflag.value) {
      const val = await formRef.value.validate();
      if (!val) {
        popVisible.value = flag;
      } else {
        done(false);
      }
    } else if (
      handleEditchildflag.value &&
      recordBtnkey.value === '' &&
      optionCodebj.value === ''
    ) {
      const val = await formRef2.value.validate();
      if (!val) {
        const { data } = await batchSaveOrUpdate({
          planListNo: props.otherParams?.record?.planListNo,
          planSupplierVOList: [{ ...pushdata.value.form }],
        });
        await getlist2('1');
        if (data) {
          Message.success('修改成功');
        } else {
          Message.error('修改失败');
        }
        popVisible.value = flag;
      } else {
        done(false);
      }
    } else if (handleEditchildflag.value && recordBtnkey.value === 'append') {
      pushdata.value.form.id = '';

      const val = await formRef2.value.validate();
      if (!val) {
        const { data } = await batchSaveOrUpdate({
          planListNo: props.otherParams?.record?.planListNo,
          planSupplierVOList: [{ ...pushdata.value.form }],
        });
        await getlist2('1');
        if (data) {
          Message.success('添加成功');
        } else {
          Message.error('添加失败');
        }
        popVisible.value = flag;
      } else {
        done(false);
      }
    } else if (handleEditchildflag2.value) {
      const val = await formRef3.value.validate();
      if (!val) {
        const { data } = await batchUpdateForSimple([
          { ...pushdata.value.form },
        ]);
        if (data) {
          Message.success('添加成功');
        } else {
          Message.error('添加失败');
        }
        popVisible.value = flag;
      } else {
        done(false);
      }
    }

    await getdatalist();
    emit('result', 'refresh');
  };

  // 弹窗取消
  const handleCancel = (flag: boolean) => {
    popVisible.value = flag;
  };
  const optionCodebj = ref('');
  // 编辑详情表单
  const handleEditchild = () => {
    console.log(
      '编辑详情表单',
      props.otherParams,
      props.otherParams?.optionCode
      // props.otherParams.codethis,
      // props.otherParams.record,
      // props.otherParams.optionCode.length
    );
    optionCodebj.value = props.otherParams?.optionCode;
    codethis.value = props.otherParams.codethis
      ? props.otherParams.codethis
      : 0;
    popUpTitle.value = '修改内容';
    compilechangeflag.value = false;
    handleEditchildflag.value = true;
    appendflag.value = true;
    popVisible.value = !popVisible.value;
  };

  // 批量修改报价状态（报价,不报价）
  const batchUpdateQuoteStatusapi = async (idLists: any, code: number) => {
    if (idLists.length > 0) {
      await batchUpdateQuoteStatus({
        idList: idLists,
        isQuote: code,
      });
      Message.success('操作成功！');
      getlist(props.otherParams.record.id);
    } else {
      Message.warning('请选择先选择数据再进行操作！');
    }
  };

  // 批量修改报价完成
  const batchQuoteFinishapi = async (idLists: any) => {
    if (idLists.length > 0) {
      const { data } = await batchQuoteFinish({
        idList: idLists,
      });
      if (data) {
        getlist(props.otherParams.record.id);
        selectedKeys2.value = [];
        Message.success('报价完成！');
      }
    } else {
      Message.warning('请选择先选择数据再进行操作！');
    }
  };

  // 报价信息维护子表单api
  const getlist = async (id: any) => {
    renderData2.value = [];
    const { data } = await selectQuoteItemByPage({
      pmsQuoteId: id,
      pageNo: pageNo.value,
      pageSize: pageSize.value,
    });
    console.log(data.list);
    renderData2.value = data.list;
    total.value = data.total;
    isLoading2.value = false;
  };

  // 选商方式确认子表单api
  const getlist2 = async (id: any) => {
    renderData2.value = [];
    const { data } = await pageByPlanListNo(
      props.otherParams?.record?.planListNo
    );
    console.log(data.list, id);
    renderData2.value = data.list;
    total.value = data.total;
    isLoading2.value = false;
  };

  const activeRadio = ref('');
  const openModall = async () => {
    openModal();
    recordid.value = props.otherParams.record.id;
    activeRadio.value = props.otherParams?.activeRadio;
    console.log('====================================');
    console.log(props.otherParams, props.otherParams.activeRadio);
    console.log('====================================');
    await getdatalist();
  };

  const openModall2 = async () => {
    emit('result', '', '', props.otherParams, true);
  };

  // 获取子表单数据
  const getdatalist = async () => {
    switch (props?.otherParams?.batchBtnType) {
      case 'quotation':
        await getlist(props.otherParams.record.id);
        break;
      case 'selequot':
        await getlist2(props.otherParams.record.id);
        break;
      default:
        console.error('batchBtnType', props?.otherParams?.batchBtnType);
    }
  };

  const onOk = (dateString: string) => {
    console.log('onOk: ', dateString);
    pushdata.value.form.quoteValidDate = dateString;
  };
  const onOk2 = (dateString: string) => {
    console.log('onOk2: ', dateString);
    pushdata.value.form.quoteDate = dateString;
  };

  const selectSupplier = (data: any) => {
    console.log('====================================');
    console.log(
      '生产制造厂家： itemManufactureFactoryCode',
      data.supplierCode,
      data.supplierChinese
    );
    console.log('====================================');
    pushdata.value.form.itemManufactureFactoryCode = data.supplierCode;
    pushdata.value.form.itemManufactureFactory = data.supplierChinese;
  };
  const selectSupplier2 = (data: any) => {
    console.log('====================================');
    console.log('经销商： dealerCode', data.supplierCode, data.supplierChinese);
    console.log('====================================');
    pushdata.value.form.dealerCode = data.supplierCode;
    pushdata.value.form.dealerName = data.supplierChinese;
  };
  const execChange = async () => {
    const { data } = await execTaxCalculates(pushdata.value.form);
    if (data) {
      Object.assign(pushdata.value.form, data);
    }
    console.log(data);
  };
  onMounted(async () => {
    if (pushdata.value.form.inputType === '1') {
      selChangeflag.value = false;
      selChangeflag2.value = true;
    } else {
      selChangeflag.value = true;
      selChangeflag2.value = false;
    }
  });

  watch(
    showModal,
    async (newVal) => {
      if (!newVal) {
        emit('refresh');
      }
    },
    {
      deep: true, // 开启深度监听
      // immediate: true, // 立即触发监听
    }
  );

  // const handleChangepmsBalancePrice = async (val: any) => {
  //   const { data } = await execTaxCalculate(pushdata.value.form);
  //   pushdata.value.form = data;
  //   console.log('====================================');
  //   console.log(val);
  //   console.log('====================================');
  // };

  // const handleChangepmsInvTaxPrice = async (val: any) => {
  //   const { data } = await execTaxCalculate(pushdata.value.form);
  //   pushdata.value.form = data;
  //   console.log('====================================');
  //   console.log(val);
  //   console.log('====================================');
  // };

  // const handleChangeexTaxPrice = async (val: any) => {
  //   const { data } = await execTaxCalculate(pushdata.value.form);
  //   pushdata.value.form = data;
  //   console.log('====================================');
  //   console.log(val);
  //   console.log('====================================');
  // };

  // const handleChangetaxRate = async (val) => {
  //   console.log('====================================');
  //   console.log(val);
  //   console.log('====================================');
  // };

  // const handleChangetaxPrice = async (val: any) => {
  //   const { data } = await execTaxCalculate(pushdata.value.form);
  //   pushdata.value.form = data;
  //   console.log('====================================');
  //   console.log(val);
  //   console.log('====================================');
  // };

  // const handleChangepmsInvQty = async (val: any) => {
  //   const { data } = await execUintRateCalculate(pushdata.value.form);
  //   pushdata.value.form = data;
  //   console.log('====================================');
  //   console.log(val);
  //   console.log('====================================');
  // };

  // const handleChangeinvPurQty = async (val: any) => {
  //   const { data } = await execUintRateCalculate(pushdata.value.form);
  //   pushdata.value.form = data;
  //   console.log('====================================');
  //   console.log(val);
  //   console.log('====================================');
  // };

  // const handleChangemdsUintRate = async (val: any) => {
  //   const { data } = await execUintRateCalculate(pushdata.value.form);
  //   pushdata.value.form = data;
  //   console.log('====================================');
  //   console.log(val);
  //   console.log('====================================');
  // };
</script>

<style lang="less" scoped>
  .selebox {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  :deep(.arco-select-view-single) {
    background: white;
  }

  :deep(.arco-select-view-single:hover) {
    background: white;
  }

  .row-btn-container {
    :deep(.arco-btn) {
      padding: 0 !important;
    }
  }

  .other-btn-container {
    margin-bottom: 10px;
  }

  .btn-class1 {
    width: 26px;
    color: #1e89ff;
    cursor: pointer;
  }

  .btn-class2 {
    width: 126px;
    color: #1e89ff;
    cursor: pointer;
  }

  .btn-class3 {
    width: 120px;
    color: #1e89ff;
    cursor: pointer;
  }

  .btn-class4 {
    width: 28px;
    color: #1e89ff;
    cursor: pointer;
  }

  .btn-class {
    width: 40px;
    color: #1e89ff;
    cursor: pointer;
  }

  :deep(.arco-picker-size-medium) {
    margin: 0 !important;
  }
</style>
